<?php

namespace App\Http\Requests\V3_2_7;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class SetShelfLocationRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'type'=>['required',Rule::in([0,1])],
            'id'=>'required|integer',
            'storage_id'=>'required|integer',
            'shelf_id'=>'nullable|integer',
        ];
    }

    /**
     * 验证错误信息.
     *
     * @return array
     */
    public function messages(): array
    {
        return [
            'type.required' => '类型参数，必传！',
            'type.in' => '类型参数错误！',
            'id.required' => '货架或货架表主键，必传！',
            'id.integer' => '货架或货架表主键，为整数！',
            'storage_id.required' => '仓库表主键，必传！',
            'storage_id.integer' => '仓库表主键，为整数！',
            'shelf_id.integer' => '货架表主键，为整数！',
        ];
    }
}
